//
//  UIView+Frame.swift
//  UIView 扩展
//
//  Created by mini on 2025/4/28.
//

import Foundation
import UIKit

extension UIView{
    
    var x: CGFloat {
        get { return frame.origin.x }
        set { frame.origin.x = round(newValue) }
    }
        
    var y: CGFloat {
        get { return frame.origin.y }
        set { frame.origin.y = round(newValue) }
    }
        
    var left: CGFloat {
        get { return frame.origin.x }
        set { frame.origin.x = round(newValue) }
    }
        
    var top: CGFloat {
        get { return frame.origin.y }
        set { frame.origin.y = round(newValue) }
    }
        
    var right: CGFloat {
        get { return frame.origin.x + frame.size.width }
        set { frame.origin.x = round(newValue - frame.size.width) }
    }
    
    var bottom: CGFloat {
        get { return frame.origin.y + frame.size.height }
        set { frame.origin.y = round(newValue - frame.size.height) }
    }
    
    var width: CGFloat {
        get { return frame.size.width }
        set { frame.size.width = newValue }
    }
        
    var height: CGFloat {
        get { return frame.size.height }
        set { frame.size.height = newValue }
    }
        
    var origin: CGPoint {
        get { return frame.origin }
        set { frame.origin = newValue }
    }
        
    var size: CGSize {
        get { return frame.size }
        set { frame.size = newValue }
    }
        
    var centerX: CGFloat {
        get { return center.x }
        set { center.x = newValue }
    }
        
    var centerY: CGFloat {
        get { return center.y }
        set { center.y = newValue }
    }
}
